package com.fighYo.edu.controller;


import com.fighYo.commonutils.R;
import com.fighYo.edu.entity.vo.SubjectNestedVo;
import com.fighYo.edu.service.EduSubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/edu/subject")
public class EduSubjectController {

    @Autowired
    private EduSubjectService subjectService;

    @PostMapping("addSubject")
    public R addSubject(MultipartFile file) {
        subjectService.saveSubject(file);
        return R.ok();
    }

    @GetMapping("getAllSubject")
    public R getAllSubject() {
        List<SubjectNestedVo> nestedVos = subjectService.nestedList();
        return R.ok().data("items", nestedVos);
    }

}
